/*
    This file is part of Raptor.

    Raptor is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Raptor is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Raptor.  If not, see <http://www.gnu.org/licenses/>.

 */

#ifndef DOWNLOADMODEL_H
#define DOWNLOADMODEL_H

#include <QAbstractItemModel>
#include <QStandardItemModel>
#include <QDir>
#include <QFileIconProvider>

#include "xmlFileLoader.h"

class FDownloadModel : public QStandardItemModel //QAbstractItemModel
{

	public:

		enum columnData
		{
			CD_FILENAME,
			CD_PROGRESS,
			CD_SPEED,
			CD_TIMELEFT,
			CD_SIZE,
			CD_LINK,
			CD_ELAPSED,
			CD_HIDDEN_DLID,
			CD_HIDDEN_STATE,
			CD_HIDDEN_ID,
		};

		//FDownloadModel(int rows, int columns, QObject *parent = 0);
		explicit FDownloadModel(QObject *parent = 0);
		~FDownloadModel();

		// FDownloadModel specific API

		void addDownload(const QString &hoster, const QString &folder, const QString filename, const QString &url, const long &id, const int &state = xmlFileLoader::STATE_WAITING, const uint downloaded=0, const uint size=0);
		QPair<QStandardItem *, QStandardItem *> addFolder(const QString &hoster, const QString &folder);

		QStandardItem * createHoster(const QString &hoster);
		QStandardItem * createFolder(QStandardItem * hoster, const QString &folder);

		QStandardItem * getFolderItem(QStandardItem * hoster, const QString &folder, bool &found);
		QStandardItem * getHosterItemByName(const QString &hoster, bool &found);

	private:
	    Q_DISABLE_COPY(FDownloadModel)

};


#endif // DOWNLOADMODEL_H
